<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/8
 * Time: 11:45
 */
namespace Admin\Model;
use Base\Model\BaseModel;
class DiseaseinfoModel extends BaseModel
{
    protected $_validate = array(
        array('name', 'require', '名称必须填写'),
        array('name', '', '疾病名称已存在', 0, 'unique', 3),
        array('name','/^[a-zA-Z_\x{4e00}-\x{9fa5}]+$/u', '疾病名称不符合规则！',3),
    );
    protected $_link=array(
        //疾病所属分类
        'type' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name'    => 'diseasetype',
            'foreign_key' => 'typeid',
            'parent_key' => 'id',
            'mapping_fields' => 'id,typename'
        ),
        //疾病所属科室
        'department' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name'    => 'departmentinfo',
            'foreign_key' => 'departmentid',
            'parent_key' => 'id',
            'mapping_fields' => 'id,name'
        ),
        //疾病所属身体部位
        'body' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name'    => 'bodyinfo',
            'foreign_key' => 'bodyid',
            'parent_key' => 'id',
            'mapping_fields' => 'id,name'
        )
    );
    protected $_auto = array(
        array('status', '1'),
    );

}